<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml"
                xmlns:security="http://www.springframework.org/security/tags"

>
    <ui:define name="title">信用卡代偿订单</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"
                                         />
                        <p:columnToggler datasource="CreditCompensatoryOrderDataTable" trigger="toggler"
                                         />
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         rendered="#{creditCompensatoryOrderListBean.isNormal() }"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         rendered="#{security:areAllGranted('COMPENSATION_ORDER_EXPORT')}"
                                         ajax="false">
                            <p:dataExporter type="xls" target="CreditCompensatoryOrderDataTable" fileName="export"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;">
                                <p:outputLabel for="prdId" value="产品"/>
                                <p:selectOneMenu id="prdId" value="#{creditCompensatoryOrderListBean.$.product_id}"
                                				 filter="true" filterMatchMode="contains">
                                     <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                   	 <f:selectItems
                                            value="#{creditCompensatoryOrderListBean.commProductIds}"
                                            var="product"
                                            itemLabel="#{product.name}" itemValue="#{product.productId}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="orderStatus" value="订单状态"/>
                                <p:selectOneMenu id="orderStatus" value="#{creditCompensatoryOrderListBean.$.status}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="待确认" itemValue="10" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="处理中" itemValue="11" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="成功" itemValue="12" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="失败" itemValue="13" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="中止" itemValue="14" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="异常" itemValue="15" noSelectionOption="true"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="orderid" value="订单编号"/>
                                <p:inputText id="orderid" value="#{creditCompensatoryOrderListBean.$.id}" style="width:100%"/>

                                <p:outputLabel for="trans_id" value="交易号"/>
                                <p:inputText id="trans_id" value="#{creditCompensatoryOrderListBean.$.trans_id}" style="width:100%"/>

                                <p:outputLabel for="entrance" value="入口"/>
                                <p:inputText id="entrance" value="#{creditCompensatoryOrderListBean.$.channel_from}" style="width:100%"/>

                                <p:outputLabel for="idcard" value="身份证号"/>
                                <p:inputText id="idcard" value="#{creditCompensatoryOrderListBean.$.idcard}" style="width:100%"/>

                                <p:outputLabel for="petname" value="姓名"/>
                   				<p:inputText id="petname" value="#{creditCompensatoryOrderListBean.$.petname}" style="width:100%"/>

                   				<p:outputLabel for="mobnum" value="手机号"/>
                   				<p:inputText id="mobnum" value="#{creditCompensatoryOrderListBean.$.mobnum}" style="width:100%"/>


                   				<p:outputLabel for="createStartDate" value="开始日期"/>
                                <p:calendar id="createStartDate" value="#{creditCompensatoryOrderListBean.$.startDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="createEndDate" value="结束日期"/>
                                <p:calendar id="createEndDate" value="#{creditCompensatoryOrderListBean.$.endDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="source" value="订单来源"/>
                                <p:selectOneMenu id="source" value="#{creditCompensatoryOrderListBean.$.source}"
                                                 filter="true" filterMatchMode="contains">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems value="${creditCompensatoryOrderListBean.dictionaries[DictionaryCode.DAICHANGTYPE]}"
                                        var="dic" itemValue="${dic.name}" itemLabel="${dic.value1}">
                                    </f:selectItems>
                                </p:selectOneMenu>


                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="CreditCompensatoryOrderDataTable"
                                         style="width: 100%"
                                         update="@form"
                                         var="record"
                                         value="#{creditCompensatoryOrderListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="97%"
                                         reflow="true"
                                         selection="#{creditCompensatoryOrderListBean.selectedRecords}"
                                         resizableColumns="true"
                                         >

                                <p:column headerText="订单创建时间">
                                    <h:outputText value="#{record.createtime}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="订单号">
                                    <h:outputText value="#{record.orderid}"/>
                                </p:column>
                                <p:column headerText="交易号">
                                    <h:outputText value="#{record.trans_id}"/>
                                </p:column>
                                <p:column headerText="产品">
                                    <h:outputText value="#{creditCompensatoryOrderListBean.translateProduct(record.prdocu_id)}"/>
                                </p:column>
                                <p:column headerText="渠道">
                                    <h:outputText value="#{creditCompensatoryOrderListBean.translateProductChannel(record.channel)}"/>
                                </p:column>
                                <p:column headerText="姓名">
                                    <h:outputText value="#{record.petname}"/>
                                </p:column>
                                <p:column headerText="手机号">
                                    <h:outputText value="#{record.mobnum}"/>
                                </p:column>
                                <p:column headerText="身份证号">
                                    <h:outputText value="#{record.idcard}"/>
                                </p:column>
                                <p:column headerText="用户剩余额度">
                                    <h:outputText value="#{record.left_limit}"/>
                                </p:column>
                                <p:column headerText="银行名称">
                                    <h:outputText value="#{record.bankname}"/>
                                </p:column>
                                <p:column headerText="信用卡卡号">
                                    <h:outputText value="#{record.card_no}"/>
                                </p:column>
                                <p:column headerText="申请金额">
                                    <h:outputText value="#{record.amount}"/>
                                </p:column>
                                <p:column headerText="分期数">
                                    <h:outputText value="#{record.peroid}"/>
                                </p:column>
                                <p:column headerText="手续费">
                                    <h:outputText value="#{record.fee}"/>
                                </p:column>
                                <p:column headerText="还款日期">
                                    <h:outputText value="#{record.bill_date}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="订单状态">
                                    <h:outputText value="#{creditCompensatoryOrderListBean.traslationOrderStatus(record.status)}"/>
                                </p:column>
                                <p:column headerText="入口">
                                    <h:outputText value="#{record.channel_from}"/>
                                </p:column>

                                <p:column headerText="操作" width="10%" rendered="#{security:areAllGranted('COMPENSATION_ORDER_CANCEL')}">
                                    <p:splitButton icon="fa fa-play-circle"
                                                   process="@this">
                                        <p:menuitem value="取消订单" icon="fa fa-history"
                                                    process="@this"
                                                    update="@form"
                                                    action="#{creditCompensatoryOrderListBean.cancelOrder(record.trans_id)}"
                                                    rendered="#{record.status  == '11'}"
                                        >
                                            <p:confirm header="信息提示" message="确定取消此订单么？" icon="ui-icon-alert" width="10%"/>
                                        </p:menuitem>
                                    </p:splitButton>
                                    <p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
                                        <p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes"
                                                         icon="ui-icon-check"/>
                                        <p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
                                    </p:confirmDialog>
                                </p:column>
                                <p:column headerText="订单来源">
                                    <h:outputText value="#{record.source}"/>
                                </p:column>

                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
